package com.safe.first.domain.order.model;

import com.safe.first.domain.order.constants.OrderType;
import com.safe.first.domain.order.factory.GoodsOrderFactory;
import com.safe.first.domain.order.model.vo.OrderLog;
import com.safe.first.domain.order.model.vo.PriceItem;
import com.safe.first.domain.order.service.OrderPriceService;
import com.safe.first.domain.user.User;
import lombok.Data;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Mickey
 * @since 2022/5/28
 **/
@Data
public class GoodsOrder implements Order {

    private Long id;
    private Long uid;
    private Long addressId;
    private BigDecimal totalFee;
    private List<OrderLog> orderLogs;
    private List<PriceItem> priceItems;
    private OrderType type = OrderType.GOODS;

    public GoodsOrder(OrderPriceService orderPriceService,
                      User user,
                      GoodsOrderFactory.CreateGoodsOrderParam createGoodsOrderParam) {
        this.priceItems = orderPriceService.price(createGoodsOrderParam.getSkus(), user);
        this.orderLogs = new ArrayList<>();
        this.orderLogs.add(new OrderLog(1L, "创建订单"));
    }

}
